import type { BasicColumn, FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import * as selfFunc from './supplier.func';

export const searchFormSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'name',
    colProps: {
      span: 8,
    },
    component: 'Input',
  },
  {
    label: '联系人',
    field: 'contact',
    colProps: {
      span: 8,
    },
    component: 'Input',
  },
  {
    label: '状态',
    field: 'status',
    colProps: {
      span: 8,
    },
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'is_open',
      stringToNumber: true,
    },
  },
];

export const columns: BasicColumn[] = [
  {
    title: '名称',
    dataIndex: 'name',
    align: 'center',
  },
  {
    title: '联系人',
    dataIndex: 'contact',
    align: 'center',
  },
  {
    title: '联系电话',
    dataIndex: 'contactNumber',
    align: 'center',
  },
  {
    title: '电子邮箱',
    dataIndex: 'email',
    align: 'center',
  },
  {
    title: '状态',
    dataIndex: 'statusTxt',
    align: 'center',
    customRender: selfFunc.renderStatus,
  },
  {
    title: '累计应付账款',
    dataIndex: 'totalAccountPayment',
    align: 'center',
  },
  {
    title: '地址',
    dataIndex: 'address',
    align: 'center',
  },
  {
    title: '纳税人识别号',
    dataIndex: 'taxNumber',
    align: 'center',
  },
  {
    title: '开户行',
    dataIndex: 'bankCodeTxt',
    align: 'center',
  },
  {
    title: '账号',
    dataIndex: 'accountNumber',
    align: 'center',
  },
  {
    title: '税率',
    dataIndex: 'taxRate',
    align: 'center',
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    align: 'center',
  },
  {
    title: '修改时间',
    dataIndex: 'updateTime',
    align: 'center',
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input',
  },
  {
    label: '名称',
    field: 'name',
    colProps: {
      span: 12,
    },
    component: 'Input',
  },
  {
    label: '联系人',
    field: 'contact',
    colProps: {
      span: 12,
    },
    component: 'Input',
  },
  {
    label: '联系电话',
    field: 'contactNumber',
    colProps: {
      span: 12,
    },
    component: 'Input',
  },
  {
    label: '电子邮箱',
    field: 'email',
    colProps: {
      span: 12,
    },
    component: 'Input',
  },
  {
    label: '备注',
    field: 'remark',
    colProps: {
      span: 24,
    },
    component: 'InputTextArea',
  },
  {
    label: '类型',
    field: 'typeId',
    colProps: {
      span: 12,
    },
    component: 'JTreeSelect',
    componentProps: {
      dict: 'supplier_type,title,id',
      hasChildField: 'is_leaf',
      pidValue: '0',
      pidField: 'parent_id',
      converIsLeafVal: 0,
    },
  },
  {
    label: '累计应付账款',
    field: 'totalAccountPayment',
    colProps: {
      span: 12,
    },
    component: 'InputNumber',
  },
  {
    label: '地址',
    field: 'address',
    colProps: {
      span: 12,
    },
    component: 'Input',
  },
  {
    label: '纳税人识别号',
    field: 'taxNumber',
    colProps: {
      span: 12,
    },
    component: 'Input',
  },
  {
    label: '开户行',
    field: 'bankCode',
    colProps: {
      span: 12,
    },
    component: 'JDictSelectTag',
    componentProps: {
      type: 'select',
      dictCode: 'bank_code',
    },
  },
  {
    label: '账号',
    field: 'accountNumber',
    colProps: {
      span: 12,
    },
    component: 'Input',
  },
  {
    label: '税率',
    field: 'taxRate',
    colProps: {
      span: 12,
    },
    component: 'InputNumber',
  },
];
